﻿
namespace Patterns4Net.PatternEnforcer.Core.Patterns
{
    using Patterns4Net.Core.CecilExtensions;
    using Patterns4Net.Core.Patterns;

    [PatternCheckerExport(typeof(SimpleFactoryMethod))]
    public sealed class SimpleFactoryMethodChecker : FluentPatternChecker<SimpleFactoryMethod>
    {
        public SimpleFactoryMethodChecker()
        {
            this.Method(pattern => pattern.TargetMethod)
                .Check(
                    method => method.MethodReturnType.IsVoid() == false,
                    method => string.Format(ErrorMessages.SimpleFactoryMethodShouldNotBeVoid, method.Name, method.DeclaringType.Name));
        }
    }
}
